package cn.Jackpy.FactoryPattern;

/**
 * @auther: kpy
 * @version: 1.0
 * @Package: cn.Jackpy.FactoryPattern
 * @data: 2024/8/26 21:44
 * @discription:
 **/
public class ShapeServiceImpl {

    private String shape;

    public ShapeServiceImpl(String shape) {
        this.shape = shape;
    }

    public ShapeInterFace getShape() throws Exception {
        ShapeInterFace shapeInterFace = null;
        if (shape == null) {
            return null;
        } else if (shape.equalsIgnoreCase("circle")) {
            shapeInterFace = new CircleImpl();
            return shapeInterFace;
        } else if (shape.equalsIgnoreCase("square")) {
            shapeInterFace = new SquareImpl();
            return shapeInterFace;
        } else {
            throw new Exception("nothing to do!!!");
        }
    }
}
